<?php
$title = 'Asociación de Perfiles con Permisos';
$this->headTitle($title);
?>
<h1><?php echo $this->escapeHtml($title); ?></h1>
<?php
$i = 0;
$form = $this->form;
$form->setAttribute('action', $this->url('pf_pm'));
$form->prepare();
echo $this->form()->openTag($form);
$form->get('perfil_id')->setValue($perfil_id);
echo $this->formRow($form->get('perfil_id'));
?>

<br>
<table align="right">
<tr>
   <td><?php echo $this->formRow($form->get('perfiles')); ?></td>
</tr>
<tr>
   <td align="right"><?php echo $this->formSubmit($form->get('search_submit')); ?></td>
</tr>
</table>

<br><br><br><br><br>

<table border=2 width=800 align="center">
<tr>
   <th>Perfil</th>
   <th>Modulo</th>
   <th>Acción</th>
   <th>&nbsp;</th>
</tr>
<?php foreach ($permisos as $permiso) : ?>
<tr>
   <td align="center"><?php echo $this->escapeHtml($perfil);?></td>
   <td><i><?php echo $this->escapeHtml($permiso->modulo);?></i></td>
   <td><i><?php echo $this->escapeHtml($permiso->accion);?></i></td>
   <td align="center">
      <?php
         $form->add(array(
            'type' => 'Zend\Form\Element\Checkbox',
            'name' => 'checkbox_' . $i,
            'options' => array(
               'checked_value' => 'on',
               'unchecked_value' => 'off',
            )
         ));

         if (!is_null($permiso->id_perfil_permiso)) 
            $form->get('checkbox_' . $i)->setValue(true);
         
         echo $this->formRow($form->get('checkbox_' . $i));
         $i++;
      ?>
   </td>
</tr>
<?php endforeach; ?>
</table>

<br><p style="text-indent: 64em;"><?php echo $this->formRow($form->get('save_submit')); ?></p>

<br><a href="/roles"><- atras</a>
